# Replication Archive for: 
# Coppock, Alexander and Donald P. Green. 2020. 
# "Do Belief Systems Exhibit Dynamic Constraint?" 
# The Journal of Politics, Forthcoming.

rm(list = ls())

library(tidyverse)
library(estimatr)
library(stargazer)

study_2 <- read_rds("data/clean/study_2_lucid_clean.rds")
study_2_replication <- read_rds("data/clean/studies_1_2_replications_lucid_cleaned.rds")

# Consistency Experiment 3: Spending Preferences and Direct Inducement --------

study_2_trappables <- filter(study_2, trap_set == 1)

fit_1 <- lm(spend_outcomes_average ~ Z_correction, data = filter(study_2_trappables, gov_size == 1))
fit_2 <- lm(spend_outcomes_average ~ Z_correction, data = filter(study_2_trappables, gov_size == 2))

stargazer(fit_1, fit_2,
          p = starprep(fit_1, fit_2, stat = "p.value"),
          se = starprep(fit_1, fit_2),
          dep.var.labels = c("Average Federal Spending Preferences"),
          column.labels = c("Prefer Small Gov.", "Prefer Large Gov."),
          covariate.labels = c("Correction Treatment", "Constant (Control Mean)"),
          style = "apsr",
          omit.stat = c("f", "ser", "rsq", "adj.rsq"),
          star.cutoffs = c(0.05),
          label = "tab:correction",
          notes = c("Robust standard errors are in parentheses."),
          out = "../Drafts/tables/study_4_correction.tex")


study_2_replication_trappables <- filter(study_2_replication, trap_set == 1)

fit_1 <- lm(spend_outcomes_average ~ Z_correction, data = filter(study_2_replication_trappables, gov_size == "Smaller government with fewer services"))
fit_2 <- lm(spend_outcomes_average ~ Z_correction, data = filter(study_2_replication_trappables, gov_size == "Larger government with more services"))

stargazer(fit_1, fit_2,
          p = starprep(fit_1, fit_2, stat = "p.value"),
          se = starprep(fit_1, fit_2),
          dep.var.labels = c("Average Federal Spending Preferences"),
          column.labels = c("Prefer Small Gov.", "Prefer Large Gov."),
          covariate.labels = c("Correction Treatment", "Constant (Control Mean)"),
          style = "apsr",
          omit.stat = c("f", "ser", "rsq", "adj.rsq"),
          star.cutoffs = c(0.05),
          label = "tab:correction",
          notes = c("Robust standard errors are in parentheses."),
          out = "../Drafts/tables/study_4_correction_replication.tex")

